#!/usr/bin/env python

# These are functions utilized to write text onscreen.

from panda3d.core import TextNode
from direct.gui.OnscreenText import OnscreenText

# --------------------------------
# PLACING TEXT ON SCREEN FUNCTIONS
# --------------------------------

""" Used for top-left debug text """
# ----------------------------------
def addInstructions(self, pos, msg):
# ----------------------------------
    return OnscreenText(text=msg, style=1, fg=(1,1,1,1), pos=(-1.3, pos), align=TextNode.ALeft, scale = .05)

""" Used to set top-left debug text """
# --------------------------
def setInst(self, idx, msg):
# --------------------------
    if idx >= len(self.instLoc):
        print "instLoc OOB: {0}".format(idx)
        return
    if idx >= len(self.instructions):
        print "inst OOB: {0}".format(idx)
        return
    if self.instructions[idx] is not None:
        self.instructions[idx].destroy()
    self.instructions[idx] = addInstructions(self, self.instLoc[idx], msg)

""" Used to set Game Over ending text """
# ---------------------------------
def addCenteredRedTitle(self, msg):
# ---------------------------------
    return OnscreenText(text=msg, style=3, fg=(1,0,0,1), pos=(0.0, 0.0), align=TextNode.ACenter, scale=.25)

""" Used to set ESC to Exit Subtitle text """
# ------------------------------------
def addCenteredRedSubtitle(self, msg):
# ------------------------------------
    return OnscreenText(text=msg, style=3, fg=(1,0,0,1), pos=(0.0, -0.1), align=TextNode.ACenter, scale=.05)

""" Used to set Game Over ending text """
# ---------------------------------
def addCenteredEffectText(self, msg):
# ---------------------------------
    return OnscreenText(text=msg, style=3, fg=(1,1,1,1), pos=(0.0, 0.4), align=TextNode.ACenter, scale=.1)

""" Init Time Elapsed Counter """
# -----------------------
def addTimeElapsed(self):
# -----------------------
    return OnscreenText(text="Time Elapsed: 0", style=1, fg=(1,1,1,1), pos=(+1.3, 0.90), align=TextNode.ARight, scale = .05, mayChange=True)

